﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dingding.Helper;

using System.Net;
using System.Text;

using System.Data;
using System.Collections;
using System.IO;

namespace DingApi
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
         // this.TextBox1.Text =  PostWebApi3("http://localhost:58353/api/Padb22/PostPadb22_Info"); 

         // this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/Paam01/PostPaam01_Info"); 

           // this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/UpFile/PostGetAllFiles");
           // this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/Index/PostIndex_Load"); 

             this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/Pasi15");
            //this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/Paef11/PostPaef11_inq_asmat_no");
            // this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/paefso/PostPaefso_inq_asmat_no");

            //this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/Index/PostIndex_Load");

          //  this.TextBox1.Text = PostWebApi3("http://localhost:58353/api/padb22/PostPadb22");

            




        }





        private static string PostWebApi3(string host)
        {
            string result = "";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(host);
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            #region 添加Post 参数
            StringBuilder builder = new StringBuilder();



   
            builder.AppendFormat("{0}={1}", "PAGE_NO", "1");
            //builder.AppendFormat("{0}={1}", "table_rec", "[{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"W\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1500029\",\"ASMAT_NAME\":\"弹垫\",\"SPEC\":\"10  65Mn  GB/T93\",\"UNIT\":\"片\",\"QUANTITY\":\"1\",\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\" \",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"},{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"W\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1500031\",\"ASMAT_NAME\":\"弹垫\",\"SPEC\":\"8  65Mn  GB/T93\",\"UNIT\":\"片\",\"QUANTITY\":\"2\",\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\" \",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"},{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"W\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1700052\",\"ASMAT_NAME\":\"内六角\",\"SPEC\":\"M8*45  8.8级  GB/T70.1\",\"UNIT\":\"只\",\"QUANTITY\":\"3\",\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\"AA22500335\",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"},{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"0\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1700083\",\"ASMAT_NAME\":\"内六角\",\"SPEC\":\"M10*30  8.8级  GB/T70.1\",\"UNIT\":\"只\",\"QUANTITY\":0,\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\" \",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"}]");

            //复制跟踪代码，https://www.sojson.com/ 网站去转义
            //builder.Append("&");
            //builder.AppendFormat("{0}={1}", "table_rec", "[{\"REC_CREATOR\":\"114664\",\"REC_CREATE_TIME\":\"2022-09-27\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\" \",\"COMPANY_CODE\":\"LT\",\"COMPANY_CNAME\":\"常熟市龙腾特种钢有限公司\",\"BRANCH_CODE\":\"T\",\"DPTMENT_CODE\":\" \",\"MAT_NO\":\"SCTX22092700814\",\"PSC\":\" \",\"PROD_CODE\":\"Y01\",\"PROD_CNAME\":\"圆钢\",\"PROD_GRADE\":\" \",\"LOT_NO\":\"B22091267-1\",\"STOCK_CHAR\":\"TA5\",\"STOCK_NO\":\"1314-耐磨材料钢成品库\",\"STOCK_TYPE\":\" \",\"VEHICLE_NO\":\" \",\"MAT_WT\":3.187,\"WITHOUT_TAX_AMT\":0,\"ACT_WT\":0,\"THEORY_WT\":0,\"SG_CODE\":\" \",\"SG_SIGN\":\"A105\",\"MAT_NUM\":5,\"MAT_SPEC_DESC\":\"130\",\"MAT_SPEC1\":0,\"MAT_SPEC2\":0,\"MAT_SPEC3\":6000,\"MAT_SPEC4\":0,\"MAT_SPEC5\":0,\"MAT_SPEC6\":\" \",\"PRODUCT_FLAG\":\"0\",\"PONO_NO\":\"B2-2211516\",\"PONO_LOT_NO\":\" \",\"BLAST_FURNACE_NO\":\" \",\"STEEL_LADLE_NO\":\" \",\"JOINT_NO\":\" \",\"PACK_MODE_CODE\":\" \",\"BACKLOG_CODE\":\" \",\"IN_STOCK_MODE\":\" \",\"IN_STOCK_TIME\":\" \",\"IN_STOCK_NO\":\" \",\"IN_STOCK_APPLY_NO\":\" \",\"SALE_ORDER_SUB_NO\":\" \",\"CUSTOMER_CODE\":\" \",\"WHOLE_BACKLOG_CODE\":\" \",\"UNIT_CODE\":\" \",\"MAT_MANAGE_MODE\":\"0\",\"PLAN_NO\":\" \",\"PRODUCT_PACK_FLAG\":\"0\",\"PRODUCT_PACK_TIME\":\" \",\"ST_NO\":\" \",\"STD_CODE\":\" \",\"SG_STD\":\"GB/T12228-2006\",\"MTRL_NO\":\" \",\"MTRL_TEXT\":\" \",\"PROD_MAKER\":\" \",\"PROD_TIME\":\" \",\"PROD_SHIFT_NO\":\" \",\"PROD_SHIFT_GROUP\":\" \",\"PURC_ORDER_SUB_NO\":\" \",\"PURC_STD_CODE\":\" \",\"PURC_STD_DESC\":\" \",\"ARRI_STOCK_SUB_NO\":\" \",\"SUPPLIER_CODE\":\" \",\"MANUFACT_CODE\":\" \",\"ORIGIN_PRICE_TYPE_CODE\":\" \",\"ORIGIN_PURC_PRICE\":0,\"ORIGIN_SETTLE_PRICE\":0,\"ORIGIN_SETTLE_NUM\":0,\"ORIGIN_BALANCE_FLAG\":\" \",\"ORIGIN_HEAT_NO\":\" \",\"QUAL_GRADE_CODE\":\"正品\",\"QUAL_GRADE_DESC\":\" \",\"QUAL_GRADE_MAKER\":\" \",\"QUAL_GRADE_TIME\":\" \",\"LOCK_FLAG\":\" \",\"REPAIR_FLAG\":\"0\",\"LOCATION_NO\":\" \",\"LAYER_NO\":\" \",\"REMARK\":\"X\",\"RAW_SORT\":\" \",\"FIX_FLAG\":\"0\",\"FIELD_N1\":\"4\"}]");

            //builder.AppendFormat("{0}={1}", "table_rec", "[{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"W\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1500029\",\"ASMAT_NAME\":\"弹垫\",\"SPEC\":\"10  65Mn  GB/T93\",\"UNIT\":\"片\",\"QUANTITY\":\"1\",\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\" \",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"},{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"W\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1500031\",\"ASMAT_NAME\":\"弹垫\",\"SPEC\":\"8  65Mn  GB/T93\",\"UNIT\":\"片\",\"QUANTITY\":\"2\",\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\" \",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"},{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"W\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1700052\",\"ASMAT_NAME\":\"内六角\",\"SPEC\":\"M8*45  8.8级  GB/T70.1\",\"UNIT\":\"只\",\"QUANTITY\":\"3\",\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\"AA22500335\",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"},{\"REC_CREATOR\":\"111656\",\"REC_CREATE_TIME\":\"20221007203932\",\"REC_REVISOR\":\" \",\"REC_REVISE_TIME\":\" \",\"ARCHIVE_FLAG\":\"0\",\"COMPANY_CODE\":\"NM\",\"COMPANY_CNAME\":\"常熟市龙特耐磨球有限公司\",\"BRANCH_CODE\":\"E\",\"DPTMENT_CODE\":\"EB\",\"APPLY_BILL_NO\":\"AL22A01187\",\"APPLY_STATUS\":\"40\",\"ASMAT_NO\":\"BZC1700083\",\"ASMAT_NAME\":\"内六角\",\"SPEC\":\"M10*30  8.8级  GB/T70.1\",\"UNIT\":\"只\",\"QUANTITY\":0,\"GET_NUM\":50,\"STOCK_NO\":\"C30\",\"REMARK\":\"出库完成，关闭\",\"ASSIST_UNIT\":\" \",\"ASSIST_NUM\":0,\"GET_ASSIST_NUM\":0,\"PA_CON_FAC_RT\":1,\"OLDTONEW_FLAG\":\"1\",\"EXE_AM_REC_NUM\":0,\"USE\":\" \",\"APN\":\"23\",\"ENGINEER_PROJECT_NO\":\" \",\"PURCHASE_APPLY_BILL_NO\":\" \",\"AUDIT_FLAG\":\"0\",\"AUDIT_TIME\":\" \",\"AUDIT_OPINION\":\" \",\"AUDIT_PERSON_NAME\":\" \",\"OLD_QUANTITY\":0,\"EVENT_DESC\":\" \",\"IBN\":\"AL22A01187\"}]");


 

             builder.Append("&");
             builder.AppendFormat("{0}={1}", "APPID", "SHKJ");



            

           
            builder.Append("&");
            builder.AppendFormat("{0}={1}", "BILL_STATUS", "20");

            builder.Append("&");
            builder.AppendFormat("{0}={1}", "FORMNAME", "PASI01_INFO");

            builder.Append("&");
            builder.AppendFormat("{0}={1}", "NAME_SUB", "HXE0102156");

           
            
            //builder.Append("&");
            //builder.AppendFormat("{0}={1}", "ASSIST_NUM", "20");

             //builder.Append("&");
             //builder.AppendFormat("{0}={1}", "COMPANY_CODE", "LT");

             //builder.Append("&");
             //builder.AppendFormat("{0}={1}", "FORMNAME", "PAEF12");

             //builder.Append("&");
             //builder.AppendFormat("{0}={1}", "QUANTITY", "0.9");


             //builder.Append("&");
             //builder.AppendFormat("{0}={1}", "STOCK_NO", "CK3");

            builder.Append("&");
            builder.AppendFormat("{0}={1}", "USERID", "admin");
            builder.Append("&");
            builder.AppendFormat("{0}={1}", "USERNAME", "王标");

      


 


            byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
            req.ContentLength = data.Length;
            using (Stream reqStream = req.GetRequestStream())
            {
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();
            }
            #endregion
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            Stream stream = resp.GetResponseStream();
            //获取响应内容
            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
            {
                result = reader.ReadToEnd();
            }
            return result;
        }


        


    }
}